﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Models;
using LocalService;
using FileService;

namespace PcBackgroundMgr.Controls
{
    /// <summary>
    /// ExhibitItemCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class ExhibitItemCtrl : ExhibitItemCtrlBase
    {
        public ExhibitItemCtrl()
        {
            InitializeComponent();
        }

        private void ExhibitItemCtrlBase_Loaded(object sender, RoutedEventArgs e)
        {
            Exhibit model = DataContext as Exhibit;
            if (model != null)
            {
                //MooMaSource = new BitmapImage(new Uri(model.MooMaUrl));
                MooMaSource = new BitmapImage(new Uri(FileFactory.GetUrl(model.MooMaUrl,FolderEnum.IMAGE)));
            }
        }
    }

    [System.ComponentModel.DesignTimeVisible(false)]
    public class ExhibitItemCtrlBase : ContentControl
    {

        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string),
            typeof(ExhibitItemCtrlBase), new UIPropertyMetadata(""));


        public bool IsHotspot
        {
            get { return (bool)GetValue(IsHotspotProperty); }
            set { SetValue(IsHotspotProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsHot.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsHotspotProperty =
            DependencyProperty.Register("IsHotspot", typeof(bool),
            typeof(ExhibitItemCtrlBase), new UIPropertyMetadata(false));


        public ImageSource MooMaSource
        {
            get { return (ImageSource)GetValue(MooMaSourceProperty); }
            set { SetValue(MooMaSourceProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MooMaSource.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty MooMaSourceProperty =
            DependencyProperty.Register("MooMaSource", typeof(ImageSource),
            typeof(ExhibitItemCtrlBase),
            new UIPropertyMetadata(new BitmapImage(new Uri("pack://application:,,,/Images/ico_logo.png"))));

    }
}
